Skip to content

[CDAP-21245] Fix: Propagate parent logging context to asynchronous action and fork threads#16129

Open
riyaa14 wants to merge 1 commit into
developfrom
fix/logging-context-propagation
Open

[CDAP-21245] Fix: Propagate parent logging context to asynchronous action and fork threads#16129
riyaa14 wants to merge 1 commit into
developfrom
fix/logging-context-propagation

Conversation

@riyaa14
Copy link
Copy Markdown

@riyaa14 riyaa14 commented May 18, 2026

Summary

Issue:
Logging Context doesn't get propagated in parallel branches in pipelines.

Solution:
Ensures that the LoggingContext from the current workflow thread is correctly captured and propagated to background worker threads when running asynchronous action nodes and parallel fork branches.

Changes

  • Captured the current thread's LoggingContext before spinning up new threads in executeAction and executeFork.
  • Used a try-with-resources pattern to apply the context inside the worker threads and guarantee its cleanup/restoration once execution completes.

Testing

Pipeline execution successful:

image

Before changes:

All labels aren't propagated in parallel branches.

parallel:

image

After changes:

All 10 labels are propagated.

linear

image

parallel:

image

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements logging context propagation for Workflow actions and fork branches in WorkflowDriver.java, ensuring that logs generated in worker threads carry the correct context from the parent thread. The review feedback identifies a critical issue where the catch blocks for error logging are positioned outside the try-with-resources blocks. This causes the error logs to be emitted after the logging context has been reverted, resulting in missing context information. It is recommended to nest the try-catch blocks inside the try-with-resources scope and to consider catching Throwable to ensure all failures are logged with the correct context.

@riyaa14 riyaa14 force-pushed the fix/logging-context-propagation branch from 1197f98 to 6837226 Compare May 18, 2026 11:11
@sidhdirenge sidhdirenge added the build Triggers github actions build label May 18, 2026
@sonarqubecloud
Copy link
Copy Markdown

@riyaa14 riyaa14 changed the title fix CDAP-21245: Propagate parent logging context to asynchronous action and fork threads CDAP-21245: Propagate parent logging context to asynchronous action and fork threads May 18, 2026
@riyaa14 riyaa14 changed the title CDAP-21245: Propagate parent logging context to asynchronous action and fork threads [CDAP-21245] Fix: Propagate parent logging context to asynchronous action and fork threads May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Triggers github actions build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants